<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 闭包缺点，占用资源
        // 重要作用 延伸了变量的作用范围
        function fn() {
            var num = 10;
            return function () {
                num++;
                console.log(num);
            };
        }
        var f = fn();
        // 11
        f();
        // 12
        f();
        // 13
        f();
        // 14
        f()();
        fn()();
    </script>
</body>

</html>